The present invention relates generally to graphics data processing, and in particular to methods and systems for efficiently managing memory resources in a computer system having a graphics processing unit and running several processes simultaneously on the same computer system.
As computer graphics performance increases, the ability to handle ever larger amount of graphics data has become a crucial requirement for modern computer graphics systems. Rendering pipelines have been highly optimized to carry out tightly controlled flows of graphics computations. As graphical processing units are challenged to simultaneously run multiple processes this requirement for managing memory as well as other resources in a computer system has become more important.
FIG. 1 is a block diagram showing several simultaneously running processes communicating with each other to share memory so that all of processes can run simultaneously. FIG. 1 includes a first process A, a second process B, a display driver and arrows showing the communication lines between each other. Process A communicates directly with the display driver but does not communicate directly with process B. Similarly, process B communicates directly with the display driver but does not communicate directly with process A. Therefore, process A communicates with process B indirectly so that if either of these processes requires something from the other process, then it must do so through the display driver.
The display driver has knowledge of all processes and all global information including information such as the total available memory and the amount of memory being used by process A and process B. Although memory can be managed by using the display driver, it is very inefficient to do so because the amount of bookkeeping required to do this is considerable and doing so slows down the system. Another problem with using the display driver to manage the memory of the processes as depicted in FIG. 1 is that the freeing or reduction of memory usage is asynchronous to the other processes and could create problems with the operation of process A or process B. For example, correctness problems can occur in a scenario where process B requires additional memory and requests the additional memory from the display driver which in turn allocates memory to process B that was previously assigned to process A. The correctness problems would occur when process A attempts to access the reallocated memory because it was not updated in time as to the change in memory assignments. The problems resulting from this could be that process A erases whatever is in that part of the memory, which was probably written there by process B, or there could be an error because this resource does not exist, causing corrupt rendering. Corrupt rendering in the rendering process can include a corruption of the memory used in the rendering process. The methods of avoiding this correctness problem are prohibitively expensive in terms of performance for the common case of the memory not getting reallocated. That is, tracking the allocations to recover from the case when an allocation is removed slows down the common case when no allocation is moved.
Therefore, what is needed is a system and method that allow finite resources such as memory to be managed so that several processes can run efficiently at the same time on one system.